package com.ruoyi.common.utils;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

@Component
public class EnvironmentUtil {

    private static String env = "dev";

    private static Environment environment;

    private static Set<String> activeProfiles;


    @Autowired
    public void setEnvironment(Environment environment){
        EnvironmentUtil.environment = environment;
        EnvironmentUtil.activeProfiles = new HashSet<String>(Arrays.asList(environment.getActiveProfiles()));
    }

    public static boolean isDev(){
        return activeProfiles.contains(env);
    }
}
